home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!ts14-03
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c++
- Subject: Re: overloading ->
- Date: Sat, 16 Mar 96 09:38:27 GMT
- Organization: MiddleWorld SoftWare
- Message-ID: <4ie274$pc1@sam.inforamp.net>
- References: <4id6o2$t5n@vixen.cso.uiuc.edu>
- NNTP-Posting-Host: ts14-03.tor.inforamp.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <4id6o2$t5n@vixen.cso.uiuc.edu>,
- wemccaug@prairienet.org (Wendy E. McCaughrin) wrote:
- > I realize that in addition to returning an object pointer
- > as value, a member operator -> can also return an object,
- > but I am wondering if there is a way to overload it so it
- > can return two different pointer types directly. My problem
- > is that it has to be a member operator taking no arguments,
- > so the different return-values would be the only distinction
- > and, of course, that is not enough to make them regarded as
- > different by the compiler. Any suggestions?
-
- Here's what I'm thinking. You have a primary class member function that
- returns a secondary class. The secondary class has built-in implicit type
- conversion routines that pass one value when converting to type x and another
- when converting to type y.
-
- class Primary
- {
- public:
- Secondary get(){Secondary s; s.i=0; s.c=0; return s;};
- };
-
- class Secondary
- {
- public:
- int i;
- char c;
- };
-
- Get the idea.
-
- Agrivar
-